import { createRouter, createWebHistory } from "vue-router";
import {unAuthenticated} from "../net/index.js";

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/index',
            name: 'Index',
            component: () => import('@/views/index.vue'),
            children: [
                {
                    path: 'home',
                    name: 'IndexHome',
                    component: () => import('@/views/index/Home.vue')
                },
                {
                    path: 'noticeDetail',
                    name: 'noticeDetail',
                    component: () => import('@/views/index/NoticeDetail.vue')
                },
                {
                    path: 'notices',
                    name: 'IndexNotices',
                    component: () => import('@/views/index/Notices.vue')
                },
                {
                    path: 'jobApply',
                    name: 'jobApply',
                    component: () => import('@/views/index/JobApply.vue')
                },
                {
                    path: 'jobDetail',
                    name: 'jobDetail',
                    component: () => import('@/views/index/JobDetail.vue')
                },
                {
                    path: 'jobs',
                    name: 'IndexJobs',
                    component: () => import('@/views/index/Jobs.vue')
                },
                {
                    path: 'policy',
                    name: 'IndexPolicy',
                    component: () => import('@/views/index/Policy.vue')
                }
            ]
        }
    ]
});

// router.beforeEach((to, from, next) => {
//     const isUnAuthenticated = unAuthenticated();
//     if(isUnAuthenticated && to.fullPath !== '/login') {
//         next('/login')
//     } else if(!isUnAuthenticated && to.fullPath === '/login') {
//         next('/index')
//     } else {
//         next()
//     }
// });

export default router;